package com.xiyue.leaspring.po;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name = "member")
public class Member implements Serializable {

	@Id
	private String mid;
	private String name;
	@ManyToMany(fetch = FetchType.LAZY)//启用延迟加载
	@JoinTable(name = "member_role",//描述一个关联表
			joinColumns = {@JoinColumn(name="mid")},//member与member_role表的连接
			inverseJoinColumns = {@JoinColumn(name="rid")})//通过Member找到Role中的rid的数据
	private List<Role> roles;
	public String getMid() {
		return mid;
	}
	public void setMid(String mid) {
		this.mid = mid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public List<Role> getRoles() {
		return roles;
	}
	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	@Override
	public String toString() {
		return "Member [mid=" + mid + ", name=" + name + ", roles=" + roles + "]";
	}
	
	
}
